<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>XMLReauest</title>
</head>
<body>
    <script>
        //1，创建xhr对象
        let xhr = new XMLHttpRequest();
        //监控状态变化
        xhr.onreadystatechange = function()
        {
            // //状态为done时才打印
            if(xhr.readyState!=XMLHttpRequest.DONE) return;
            console.log(xhr.response);
        }

        xhr.responseType ="text";

        xhr.onerror = function()
        {
            //错误事件处理
        }

        xhr.onload = function()
        {
            console.log(xhr.status,xhr.statusText);
        }
   
        xhr.onloadstart = function()
        {
            console.log("开始发送数据");
        }

        xhr.timeout = 2;
        //open
        xhr.open("get","https://dazi.91xjr.com/?user=Niu_brave");
        //send
        xhr.send();
    </script>
</body>
</html>